#ifndef _RM15D_H_
#define _RM15D_H_

#include "sample.h"
#include "device.h"

class RM15Device : public SerialDevice {
public:
  enum ProbeConfiguration {
    WENNER,
    DOUBLE_DIPOLE,
    TWIN_EQUAL_DISTANCE,
    TWIN_WIDE_REMOTE
  };
  
  RM15Device(std::string port, size_t baud, double probeSeparation, ProbeConfiguration configuration = TWIN_EQUAL_DISTANCE) : SerialDevice(port, baud), _probeSeparation(probeSeparation), _configuration(configuration) {}
  virtual ~RM15Device() {}

  virtual int downloadData(std::vector<Sample*>& sampleVec, const size_t totalSamplesToRead);

  double probeSeparation() const {return _probeSeparation;}
  ProbeConfiguration configuration() const {return _configuration;}

private:
  double _probeSeparation;
  ProbeConfiguration _configuration;
};

/** \brief Stores one sample as it comes from the RM15-D.*/
class RM15Sample : public Sample {
public:
  RM15Sample(RM15Device* device, int value, int gain, int current);

  /**
  \brief Returns the resistivity, in ohm-metres, of the sample, based on the probe configuration.
  */
  virtual double value() const;
  
  virtual std::string raw() const;

private:
  /**
  \brief Returns the resistance, in ohms, of the sample.
   */
  double resistance() const;

  int _value; /*!< \brief The raw value as it comes from the RM15-D. */
  int _gain; /*!< \brief The index into #gainRanges */
  int _current; /*!< \brief The index into #currentRanges */
};

#endif
